﻿using Abp.Application.Services;
using Abp.Domain.Repositories;
using Abp.Linq.Extensions;
using AbpVueDemo.JiesuanguanliDemo.FukuanDataManager.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpVueDemo.JiesuanguanliDemo.FukuanDataManager
{
    public class FukuanDataService : AsyncCrudAppService<FukuanData, FukuanDataInputDto, int, PageFukuanDataRequestDto, FukuanDataCreateDto, FukuanDataUpdateDto>, IFukuanDataService
    {
        public FukuanDataService(
        IRepository<FukuanData, int> repository) : base(repository)
        {

        }
        /// <summary>
        /// 自定义分页条件查询, 需要重写父类的CreateFilteredQuery方法,让其进行自定义条件筛选
        /// </summary>
        /// <param name="input">查询条件</param>
        /// <returns></returns>
        protected override IQueryable<FukuanData> CreateFilteredQuery(PageFukuanDataRequestDto input)
        {
            return base.CreateFilteredQuery(input)

                 .WhereIf(!string.IsNullOrEmpty(input.biaoti), c => c.biaoti.Contains(input.biaoti))
                  .WhereIf(!string.IsNullOrEmpty(input.name), c => c.name.Contains(input.name))
                   .WhereIf(input.zhuangtai > 0, c => c.zhuangtai == input.zhuangtai)
                   
                    .WhereIf(input.fukuan.HasValue, c => c.fukuan == input.fukuan);
        }
    }
}
